package com.job.ZhangMeng.Homework0715;

public class StringEx01 {

    //找出字符串内首次出现的重复次数最多的字符及重复次数
    public static void main(String[] args) {
        int max=1,count=1;
        char c=' ';
        String str="aa111netBBBB39999wwwww";
        for (int i = 0; i < str.length()-1; i++) {
            if(str.charAt(i)==str.charAt(i+1))
                count++;
            else {
                if (max < count) {   //保证重复次数最多
                    max = count;
                    c=str.charAt(i);
                }
                count = 1;        //重置count
            }
        }
        //若最后部分也是重复内容
        if (max < count) {
            max = count;
            c=str.charAt(str.length()-1);
        }
        System.out.println(c+"~"+max);

    }

}
